<?php

declare (strict_types=1);
namespace App\Model;

use Hyperf\Database\Model\SoftDeletes;

/**
 * @property int $id 运费模板id
 * @property string $tpl_name 模板名称
 * @property int $tpl_type 模板类型： 1运费模板（发货） 2邮费模板（退换货）
 * @property int $status 状态
 * @property int $sort 排序
 * @property int $shop_id 店铺id
 * @property \Carbon\Carbon $created_at 添加时间
 * @property \Carbon\Carbon $updated_at 修改时间
 * @property string $deleted_at 删除时间
 * @property int $create_by 创建人
 * @property int $update_by 修改人
 * @property int $delete_by 删除人
 * @property int $use_type 1商品运费模板  2高优先级商家运费模板 3低优先级商家运费模板
 * @property int $rule_type 1固定运费 2按件数 3按重量  4按体积
 * @property int $is_free 是否免邮1是 0否
 * @property int $is_all_area 是否全国同意1是 0按区域设置
 * @property int $other_free_set 额外免邮条件满xx
 * @property int $is_other_free 是否有额外免邮条件，满xx免
 */
class DeliveryTpl extends CloudBase
{
    use SoftDeletes;
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'fly_delivery_tpl';
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [];
    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = ['id' => 'string', 'tpl_type' => 'integer', 'status' => 'integer', 'sort' => 'integer', 'shop_id' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime', 'create_by' => 'string', 'update_by' => 'string', 'delete_by' => 'string', 'use_type' => 'integer', 'rule_type' => 'integer', 'is_free' => 'integer', 'is_all_area' => 'integer', 'other_free_set' => 'integer', 'is_other_free' => 'integer'];

    public function rules(){
        return $this->hasMany(DeliveryRule::class,'tpl_id','id')
            ->with('provinces')
            ->with('citys')
            ->with('areas')
            ;
    }
}